<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>首页</title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/iconfont.css"/>
		<link rel="stylesheet" type="text/css" href="css/lcs-font.css"/>
		<link rel="stylesheet" type="text/css" href="css/iconfont.css"/>
		<style>
			html,
			body {
				background-color: #efeff4;
			}
			
			.title {
				margin: 20px 15px 10px;
				color: #6d6d72;
				font-size: 15px;
				padding-bottom: 51px;
			}
		</style>
	</head>

	<body>
		<nav class="mui-bar mui-bar-tab">
		<a class="mui-tab-item mui-active" href="home/main.html">
			<span class="mui-icon iconfont icon-shouye1"></span>
			<span class="mui-tab-label">首页</span>
		</a>
		<a class="mui-tab-item" href="write_together/wmain.html">
			<span class="mui-icon iconfont icon-shu"></span>
			<span class="mui-tab-label">书店</span>
		</a>
		<a class="mui-tab-item" href="make/mmain.html">
			<span class="mui-icon iconfont icon-xiezi"></span>
			<span class="mui-tab-label">制作</span>
		</a>
		<a class="mui-tab-item" href="discover/dmain.html">
			<span class="mui-icon iconfont icon-faxian2"></span>
			<span class="mui-tab-label">发现</span>
		</a>
		<a class="mui-tab-item" href="personal/personal.html">
			<span class="mui-icon iconfont icon-wode1"></span>
			<span class="mui-tab-label">我的</span>
		</a>
	</nav>
		<div class="mui-content">
			
		</div>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/mui.min.js"></script>
		<script src="js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/util.js"></script>
		<script type="text/javascript">
			var vurl = "";//版本路径
			var index = 0;
			var subpages = ["home/main.html",
				"write_together/wmain.html",
				"make/mmain.html",
				"discover/dmain.html",
				"personal/personal.html"];
			(function() {
				mui.init({
					swipeBack: true //启用右滑关闭功能
				});
				var activeTab = subpages[index];
				mui.plusReady(function() {
					var self = plus.webview.currentWebview();
					
					for (var i = 0; i < subpages.length; i++) {
						var sub = plus.webview.create(
						subpages[i], subpages[i], {
							top: '0px',
							bottom: '50px'
						});
						if(i > index){
							sub.hide();
						}
						self.append(sub);
					}
		            		var backButtonPress = 0;
							mui.back = function(event) {
								backButtonPress++;
								if (backButtonPress > 1) {
									plus.runtime.quit();
								} else {
									plus.nativeUI.toast('再按一次退出应用');
								}
								setTimeout(function() {
									backButtonPress = 0;
								}, 1000);
								return false;
							};
					
				
						
					/**
					 * 根据判断view控件点击位置判断切换的tab
					 */
					mui('.mui-bar-tab').on('tap', 'a', function (){
				var targetTab = this.getAttribute('href');
				if(activeTab == targetTab){
					return;
				}
				if(mui.os.plus){
					plus.webview.show(targetTab);
					plus.webview.hide(activeTab);
					activeTab = targetTab;
				} else{
					createIframe('.mui-content', {
						url: targetTab,
						style: {
							top: '0px',
							bottom: '50px'
						}
					})
				}
			});
			function createIframe(el,opt) {
				var elContainer = document.querySelector('mui-content');
				var wrapper = document.querySelector('.mui-iframe-wrapper');
				if(!wrapper){
					wrapper = document.createElement('div');
					wrapper.className = 'mui-iframe-wrapper';
					for (var i in opt.style) {
						wrapper[i] = opt.style[i];
					}
				}	
				var iframe = document.createElement('iframe');
				iframe.src = opt.url;
				iframe.id = opt.id || opt.url;
				iframe.name = opt.id;
				wrapper.appendChild(iframe);
				elContainer.appendChild(wrapper);
			}
			
			
			
				});
				/*
			window.onload = function(){
				checkVersion();
			}
			function checkVersion(){
				var data = {
					url:"/api/version/check",
					data:{
						access_token:acctoken(),
					}
				}
				ajax(data,function(res){
					console.log("版本",res);
					if(res.data.serial_number > version){
					var list = {vurl: res.data.path_url||"",content:res.data.content};
					console.log("版本返回数据："+JSON.stringify(list));  
					mui.openWindow({
					    url: 'version-page.html?list='+JSON.stringify(list), 
					    id: 'version-page',
					    extras: list,
					 });
					}else{
						console.log("最新版");
					}
				})
				}*/
			})();
		</script>
	</body>

</html>